import java.io.IOException;
import java.net.*;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class HttpConnection extends Thread {

	URL url;

	HttpConnection(String url) {
		try {
			this.url = new URL(url);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

	public Document returnXML() {
		HttpURLConnection conn = null;
		Document xml = null;
		try {
			conn = (HttpURLConnection) url.openConnection();
			if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {

			} else {
				// Verarbeitung des Ergebnisses
				DocumentBuilderFactory dbFactory = DocumentBuilderFactory
						.newInstance();
				DocumentBuilder builder = dbFactory.newDocumentBuilder();
				xml = builder.parse(conn.getInputStream());

			}
		} catch (IOException | SAXException | ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return xml;
	}
}
